
chcp 65001

:: cd %~dp0

echo %~dp0;
pushd %~dp0

rmdir /s /q build

:: Set up the Visual Studio environment for command-line use
if exist "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" (
	call  "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
) else if exist "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Professional\Build\vcvars64.bat" (
	call  "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Professional\Build\vcvars64.bat"
) else if exist "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" (
	call  "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
) else (
	echo Can't find Visual Studio 2022 VC++. Please install VS2022 with VC++
	pause
	exit
)

REM Debug
REM Release
REM RelWithDebInfo
REM MinSizeRel

set config=RelWithDebInfo

REM Ninja is single Config Generator. Ninja must specify CMAKE_BUILD_TYPE. --config does not work on Ninja
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=%config%

:: Build the project with Ninja
cmake --build build --config=%config%

echo ------------------
echo build finish
echo -----------------

.\build\main.exe

popd
pause